package com.kaifamiao.regular;

import java.util.Scanner;

public class CheckEmail {

    public static void main(String[] args) {
        final Scanner s = new Scanner( System.in );

        // 若 @ 和 . 之间有 - 应该怎么办？
        final String regex = "\\w{5,}@\\w+[.](cn|com|net|edu)";

        String email ;
        do{
            System.out.println( "请输入邮箱地址" );
            // 读取用户输入的整行数据
            email = s.nextLine();
        } while ( !email.matches( regex ) );

        System.out.println( "你输入的邮箱地址是: " + email );

        s.close();
    }

}
